<template>
	<view>
		<uv-navbar title="系统设置" bg-color="rgba(0,0,0,.0)" :placeholder='true' leftIconSize="20px"
			leftIconColor="#313C56" :autoBack='true' titleStyle="font-size: 16px;font-weight: 800;color: #313c56;" />
		<view class="flex-column">
			<view v-for="(item,index) in list" :key="index" class="setting-item font-14 font-weight-regular" style=" color: #313C56;" @click="tap(index)">
				<view class="flex-row flex-items-center " style="margin-left: 16px; ">
					<image :src="item.icon" style="width: 32px; height: 32px;"></image>
					<text style="margin-left: 16px;">{{ item.name }}</text>
				</view>
				<view v-if="index == 0" class="flex-row flex-items-center" style="margin-right: 16px;">
					<text>{{country}} ({{ lan }})</text>
					<image src="../../static/arrow-right.png" style="width: 16px; height: 16px;"></image>
				</view>
			</view>
		</view>
		<popup ref="logoutPopup" title="确定是否退出账号?" msg="退出后不会删除本账号任何历史数据，下次登录依然可以使用本账号" confirm-bg-color="#F53F3F" type="warning" @confirm="logout">
		</popup>
		<popup ref="clearPopup" title="清理成功" msg="" confirm-bg-color="#EB7520" type="success" :showCancel="false" :showClose="false" @confirm="$refs.clearPopup.close()">
		</popup>
		<toast ref="toast"></toast>
	</view>
</template>

<script>
	import popup from "@/components/popup/popup.vue"

	export default {
		components: {
			popup,
		},
		data() {
			return {
        lan:'',
        country:'',
				list: [{
					icon: '../../static/setting-change.png',
					name: '切换语言',
					content: '中文'
				}, {
					icon: '../../static/setting-logout.png',
					name: '退出账号',
				}]
			}
		},
    mounted() {
      this.lan = this.$cookie.getLan();
      this.country = this.$cookie.getCounty_();
    },
		methods: {
			tap(index) {
				if (index == 0) {
					uni.navigateTo({
						url:'/pages/check-language/check-language'
					})
				}
			 	else if (index == 1) {
					this.$refs.logoutPopup.open()
				}
			},
      disconnectWallet() {
        this.$cookie.removeAddressToken()
      },
			/**
			 * 确定退出
			 */
			logout() {
        this.disconnectWallet()
        uni.navigateTo({
          url:"/pages/index/index"
        })
			}
		}
	}
</script>

<style>
	.setting-item {
		margin-left: 16px;
		margin-right: 16px;
		margin-top: 15px;
		background-color: #F7F9FD;
		border-radius: 12px;
		height: 64px;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	page {
		background-color: white;
	}
</style>